import { PROJECT_API_URL } from '../baseURL'
import axios from '../config'

export default {
    // 查询所有项目
    project() {
        return axios({
            url: PROJECT_API_URL + '/project',
            method: "POST",
        })
    },
    // 获取自定义属性
    getAttrs(){
        return axios({
            url: PROJECT_API_URL + '/dictionary/project',
            method: 'GET'
        })
    },
    // 分页查询
    pagination(page, size) {
        return axios({
            url: PROJECT_API_URL + '/project/page',
            method: 'POST',
            data: {
                page: page,
                size: size
            }
        })
    },
    // 新增项目
    addProject(addData){
        return axios({
            url: PROJECT_API_URL + '/project/add',
            method: 'POST',
            data: addData
        })
    },
    // 批量新增数据
    batchAdd(addDatas) {
        return axios({
            url: PROJECT_API_URL + '/project/save-many',
            method: 'POST',
            data: addDatas
        })
    },
    //删除
    delete(id) {
        return axios({
            url: PROJECT_API_URL + '/project/' + id,
            method: 'delete',
        })
    },
    // 新增额外属性
    addAttribute(value) {
        return axios({
            url: PROJECT_API_URL + '/dictionary/add/project',
            method: 'POST',
            data: {
                value: value
            }
        })
    },
    // 删除额外属性
    delAttribute(id) {
        return axios({
            url: PROJECT_API_URL + '/dictionary/' + id,
            method: 'delete',
        })
    },
    //批量删除
    batchDel(ids) {
        return axios({
            url: PROJECT_API_URL + '/project/delete-many',
            method: 'POST',
            data: ids,
        })
    },
    // 批量移动
    batchMove(ids){
        return axios({
            url: PROJECT_API_URL + '/project/move-many',
            method: 'POST',
            data:ids,
        })
    },
    // 批量复制
    batchCopy(ids){
        return axios({
            url: PROJECT_API_URL + '/project/copy-many',
            method: 'POST',
            data: ids,
        })
    },
    // 项目导出
    export(id) {
        var a = document.createElement('a');
        var url = `${PROJECT_API_URL}/project/export/${id}`;
        var filename = 'data.zip';
        a.href = url;
        a.download = filename;
        a.click()
    }
}

